// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial

SubElement := Rectangle {
    property text <=> input.text;
    property <bool> has-focus: input.has-focus;
    forward_focus: input;
    input := TextInput {
        width: 100%;
        height: 100%;
    }
}

TestCase := Rectangle {
    width: 400phx;
    height: 400phx;

    callback focus_input1();
    focus_input1 => { input1.focus(); }

    callback focus_input2();
    focus_input2 => { input2.focus(); }

    Rectangle {
        input1 := TextInput {
            width: parent.width;
            height: 200phx;
        }
    }

    input2 := SubElement {
        y: 200phx;
        width: parent.width;
        height: 200phx;
    }

    if (false) : SubElement {  }

    property<bool> input1_focused: input1.has_focus;
    property<string> input1_text: input1.text;
    property<bool> input2_focused: input2.has_focus;
    property<string> input2_text: input2.text;
}

/*
```rust
let instance = TestCase::new().unwrap();
assert!(!instance.get_input1_focused());
assert!(!instance.get_input2_focused());

instance.invoke_focus_input1();
assert!(instance.get_input1_focused());
assert!(!instance.get_input2_focused());

instance.invoke_focus_input2();
assert!(!instance.get_input1_focused());
assert!(instance.get_input2_focused());
```

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
assert(!instance.get_input1_focused());
assert(!instance.get_input2_focused());

instance.invoke_focus_input1();
assert(instance.get_input1_focused());
assert(!instance.get_input2_focused());

instance.invoke_focus_input2();
assert(!instance.get_input1_focused());
assert(instance.get_input2_focused());
```

```js
var instance = new slint.TestCase();
assert(!instance.input1_focused);
assert(!instance.input2_focused);

instance.focus_input1();
assert(instance.input1_focused);
assert(!instance.input2_focused);

instance.focus_input2();
assert(!instance.input1_focused);
assert(instance.input2_focused);
```
*/
